import request from '@/request/request'

// 分页获取调拨单
export function getTransferOrderPage(pageParams) {
    return request({
        method: "get",
        url: '/warehouse/transfer/page',
        params: pageParams
    })
}

// 获取可用的其他入库单列表（未出库的，用于调拨）
export function getAvailableInboundForTransfer() {
    return request({
        method: "get",
        url: '/warehouse/transfer/availableInbound',
    })
}

// 根据其他入库单号获取仓库信息（用于调拨）
export function getInboundWarehouseForTransfer(inboundNo) {
    return request({
        method: "get",
        url: `/warehouse/transfer/inboundWarehouse/${inboundNo}`,
    })
}

// 创建调拨单
export function createTransferOrder(transferOrder) {
    return request({
        method: "post",
        url: '/warehouse/transfer',
        data: transferOrder
    })
}

// 获取调拨单详情（包含明细）
export function getTransferOrderWithDetails(id) {
    return request({
        method: "get",
        url: `/warehouse/transfer/withDetails/${id}`,
    })
}

// 更新调拨单
export function updateTransferOrder(transferOrder) {
    return request({
        method: "put",
        url: '/warehouse/transfer',
        data: transferOrder
    })
}

// 删除调拨单
export function deleteTransferOrder(id) {
    return request({
        method: "delete",
        url: `/warehouse/transfer/${id}`,
    })
}
